package EjerciciosNoBoletin2.Ex1;

import java.awt.BorderLayout;
//import java.awt.Checkbox;
import java.awt.FlowLayout;

import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

public class Ex1 {

	
	public void montarVentana(){
		
		JFrame frame = new JFrame();
		JPanel panel1 = new JPanel();
		JPanel panel2 = new JPanel();
		
		JCheckBox checkBox1 = new JCheckBox("Dog");
		JCheckBox checkBox2 = new JCheckBox("Cat");
		JCheckBox checkBox3 = new JCheckBox("Bird");

		panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
		panel1.add(checkBox1);
		panel1.add(checkBox2);
		panel1.add(checkBox3);

		
		
		
		frame.add(panel1, BorderLayout.CENTER);
		
		String[] lista = new String[]{"Dog","Cat","Bird"};
		JComboBox combo = new JComboBox(lista);
		combo.setEditable(false);
		combo.setEnabled(true);
		combo.setSelectedIndex(-1);
		
		
		
		panel2.add(combo);
		frame.add(panel2, BorderLayout.SOUTH);
		
		JMenuBar barramenu = new JMenuBar();
	    JMenu principal = new JMenu("Menu");
	    JCheckBoxMenuItem perromenu = new JCheckBoxMenuItem("Dog");
	    JCheckBoxMenuItem gatomenu = new JCheckBoxMenuItem("Cat");
	    JCheckBoxMenuItem pajaromenu = new JCheckBoxMenuItem("Bird");
	    
	    principal.add(perromenu);
	    principal.add(gatomenu);
	    principal.add(pajaromenu);
	   
	    barramenu.add(principal);
	    frame.setJMenuBar(barramenu);


	    //Gestion Listener
	    Ex1ItemListener listener = new Ex1ItemListener(checkBox1, checkBox2, checkBox3, perromenu, gatomenu, pajaromenu);
	    
	    checkBox1.addItemListener(listener);
	    checkBox2.addItemListener(listener);
	    checkBox3.addItemListener(listener);
	    combo.addItemListener(new Ex1ItemListener());
	    
	    perromenu.addItemListener(listener);
	    gatomenu.addItemListener(listener);
	    pajaromenu.addItemListener(listener);
	    
		frame.setSize(300, 300);
		frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args){
		Ex1 ejercicio1 = new Ex1();
		ejercicio1.montarVentana();
	}
}
